*     function returns the value of the integral of the e power of minus
*     x squared times the difference of the complementary error functions
*     of RA*x and RB*x evaluated from x=RX to x=infinity
      DOUBLE PRECISION FUNCTION RFIEER(RXIN,RA,RB)
      IMPLICIT NONE
      DOUBLE PRECISION RXIN, RA, RB

      DOUBLE PRECISION RSQRPI, RCUTFX
      PARAMETER (RSQRPI=1.77245385090551)
      PARAMETER (RCUTFX=10.)

      DOUBLE PRECISION RX, RFLB82

*     the function is symmetric in x
      RX=ABS(RXIN)

      IF (RX.GT.RCUTFX) THEN
*        for large x the integral is zero because the exp(-x*x) part of
*        the integrand becomes zero and the rest stays finite
         RFIEER=0.
      ELSE
*        the function can be expressed in terms of the funtion H
*        defined in eq.12 in Litkouhi and Beck (1982)
*        RFIEER(x,a,b)=.5/sqrt(pi)*[H(b*x,1/b)-H(a*x,1/a)]
*        without combining anything (which would speed things up in some
*        cases) this can be calculated as:
         RFIEER=.5*RSQRPI*( RFLB82(RX,RB)-RFLB82(RX,RA) )
      END IF

      RETURN
      END
